<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Board extends Controller
{
	function __construct()
	{
		parent::__construct();  
        
         // 로드 언어 파일
        $this->lang->load('member');
        $this->lang->load('board');       
        $this->load->scaffolding('g4_write_bbs');
         
	}
    
    function _remap($method)
	{
	   if(method_exists($this,$method)){            
            $this->{"$method"}();
       }else{
            $this->lists();
       }
    }
/*
	function index()
	{
        
      	if (!$this->tank_auth->is_logged_in()) {
			redirect('/auth/login/');
		} else {
			$data['user_id']	= $this->tank_auth->get_user_id();
			$data['username']	= $this->tank_auth->get_username();
            
            // 사이트이 이름을 가져온다 따로 환경파일에 설정하지 않고 tank_quth 환경파일에 것을 가져왔다.
            $site_name = $this->config->item('website_name', 'tank_auth');
            $data['title'] = $site_name;
            
            $data['left'] = "left_view";
            $data['main'] = "main_view";
            $data['right'] = "right_view";
            
			$this->load->view('templates/tpl_column_3', $data);
		}
	}
  */  
    function lists()
    {
        
        $this->load->helper('file');
        
        $xmlList = '<?xml version=\"1.0\" encoding=\"utf-8\"?><groupmenu>';
        
        $query = $this->db->get('g4_group');
        foreach ($query->result() as $row)
        {
            $gr_id			= $row->gr_id;
            $gr_subject		= $row->gr_subject; 
            $xmlList.='<group  gr_id='.$gr_id.'><gr_subject><![CDATA['.$gr_subject.']]></gr_subject>';
            
            $query2 = $this->db->get('g4_board');            
            foreach ($query2->result() as $row2)
            {
                $bo_table = $row2->bo_table;
                $bo_subject = $row2->bo_subject;                
                $xmlList.='<board><bo_table><![CDATA['.$bo_table.']]></bo_table><bo_subject><![CDATA['.$bo_subject.']]></bo_subject></board>';
            }
            
        }
        
        $xmlList.='</group></groupmenu>';
                
        if(!write_file('./data/menu.xml', $xmlList))
        {
             echo 'Unable to write the file';
        }
        else
        {
            echo 'written';

        } // end else

    } // end lists
    
    function write()
    {
        // 글쓰기 화면
        $site_name = $this->config->item('website_name', 'tank_auth');
        $data['title'] = $site_name . "- 글쓰기 화면";
        
        $data['left'] = "left_view";
        $data['main'] = "main_view";
        $data['right'] = "right_view";
        
        $this->load->view('templates/tpl_column_3', $data);
        
        
    }
    
    function view()
    {
        
        $site_name = $this->config->item('website_name', 'tank_auth');
        $data['title'] = $site_name;
        
        $data['left'] = "left_view";
        $data['main'] = "main_view";
        $data['right'] = "right_view";
        
        $this->load->view('templates/tpl_column_3', $data);
        
    }
}

/* 게시판을 관리하는 컨트롤러  */
/* End of file board.php */
/* Location: ./application/controllers/board.php */